
  
function updateTips(tips, t ) {
			tips
				.text( t )
				.addClass( "ui-state-highlight" );
			setTimeout(function() {
				tips.removeClass( "ui-state-highlight", 1500 );
			}, 500 );
		};
		function checkLength(tips,o, n, min, max ) {
			if ( o.val().length > max || o.val().length < min ) {
				o.addClass( "ui-state-error" );
				updateTips(tips,n + " 长度必须在" +
					min + "和 " + max + "区间." );
				return false;
			} else {
				return true;
			}
		};

		function checkRegexp( tips,o, regexp, n ) {
			if ( !( regexp.test( o.val() ) ) ) {
				o.addClass( "ui-state-error" );
				updateTips( tips,n );
				return false;
			} else {
				return true;
			}
		};
function getStart(res){
 	$(res).find("start").each(function(){ 
            var Total_Count=$(this).children("total");   //取对象 
			var type=$(this).children("type");   //取对象 
			var status=$(this).children("status");   //取对象
			getResponse(this);
			 });
 };


 function getResponse(res){
 		$(res).find("row").map(function(){
				var name=$(this).attr('name');
				var Operate_type=$(this).attr('Operate_type');
				var UserLogin=$(res).find("var[name='UserLogin']").text()
				if(UserLogin=='true'){
				//alert("登录成功点击跳转");	
				window.location.href=$(res).find("var[name='Url']").text();
					}else{
		        alert($(res).find("var[name='error']").text());
						}
				//getVar(this);
			}).get();
 };
 
  function getVar(res){
 		$(res).find("var").map(function(){
				var name=$(this).attr('name');
				var fieldName=$(this).attr('fieldName');	
				var Oper_type=$(this).attr('Oper_type');	
				var Inquire=$(this).attr('Inquire');	
				if(name=='UserLogin'){
					if($(this).text()=='true'){
						//alert("true");
						isLogin=true;
					}else{
						//alert("false");
						isLogin=false;
						alert($(res).find("var[name='error']").text());
					}
				}else if(name=='Url'){
						if(isLogin){
					     alert($(this).text());
							}	
					}
				
			}).get();
 };
 
function login(tips,name,password){
		var bValid = true;
					//allFields.removeClass( "ui-state-error" );
					bValid = bValid && checkLength(tips, name, "用户名", 1, 50 );
					bValid = bValid && checkLength(tips, password, "密码", 5, 16 );
					//bValid = bValid && checkRegexp(tips,name, /^[a-z]([0-9a-z_])+$/, "用户名必须字母开头包括 a-z, 0-9,下划线 且长度3-16." );
					// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
					
					bValid = bValid && checkRegexp(tips, password, /^([0-9a-zA-Z])+$/, "密码只允许为 : a-z 0-9 长度5-16" );

					if ( bValid ) {
ajaxHandle("../login/Login.jsp","xml","name="+name.val()+"&password="+password.val(),getResponse) ; 
						//$( this ).dialog( "close" );
					}
		};
//初始化登录对话框
function initLoginDialog(tips,name,password){
	$( "#dialog-form" ).dialog({
			autoOpen: true,
    		 stack: false, /* here */
    		 zIndex: 9999,
			height: 400,
			width: 350,
			modal: true,
			buttons: {
				"登录": function() {
					//login(tips,name,password);
				}
				//"取消": function() {
				//	$( this ).dialog( "close" );
				//}
			},
			close: function() {
				//allFields.val( "" ).removeClass( "ui-state-error" );
			}
		});
	};

// JavaScript Document